package android.slc.app.startup.task;

import android.app.Application;

import com.blankj.utilcode.util.MetaDataUtils;
import com.blankj.utilcode.util.ProcessUtils;
import com.blankj.utilcode.util.Utils;
import com.effective.android.anchors.task.Task;
import android.slc.app.startup.TaskConstant;
import android.slc.appbase.api.slc.config.ApiConfig;
import android.slc.appbase.config.ConstantsBase;

import androidx.multidex.MultiDex;

import org.jetbrains.annotations.NotNull;

public class TaskFirst extends Task {
    private final Application application;

    public TaskFirst(Application application) {
        super(TaskConstant.TASK_FIRST, false);
        this.application = application;

    }

    @Override
    protected void run(@NotNull String s) {
        Utils.init(application);//初始化工具类
        MultiDex.install(Utils.getApp());
        initMata();
    }

    /**
     * 初始化Mata
     */
    private void initMata() {
        if (ProcessUtils.isMainProcess()) {
            ConstantsBase.RELEASE = Boolean.parseBoolean(MetaDataUtils.getMetaDataInApp("ON_LINE"));
            ApiConfig.getInstance().setServiceApiAddress(MetaDataUtils.getMetaDataInApp("API"));
        }
    }
}
